﻿<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">插件管理</a></li>
        <li class="right"><a href="javascript:void(0)" onclick="LoadData()" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a></li>
    </ul>
</div>
<style>
    .lb-enabled-0 {
        color: #999
    }
</style>
<div class="main">
    <ul class="navTabs">
        <li data-tab-params="tabName:'全部',tabValue:'',tabValueObjName:'#enabled'"></li>
        <li data-tab-params="tabName:'已启用',tabValue:'1',tabValueObjName:'#enabled'"></li>
        <li data-tab-params="tabName:'未启用',tabValue:'0',tabValueObjName:'#enabled'"></li>
    </ul>
    <table class="tb-head" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td align="right">
                <div class="form-inline form-group-sm">
                    <select id="s_field" name="s_field" class="btn-xs ui-queryString ui-setName form-control">
                        <option value="name">插件名称</option>
                        <option value="author">插件作者</option>
                        <option value="introduction">插件简介</option>
                    </select>
                    <input type="hidden" name="enabled" id="enabled" class="ui-queryString" />
                    <input type="text" class="ui-queryString ui-keyword  form-control" maxlength="20" style="width:140px" placeholder="输入关键词">
                    <button type="button" class="btn btn-default btn-sm ui-queryString-search">搜索</button>
                </div>
            </td>
        </tr>
    </table>

    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered" id="tb_list">
        <thead>
            <tr>
                <td align="center">插件名称</td>
                <td align="center">介绍</td>
                <td align="center">作者</td>
                <td align="center">安装时间</td>
                <td align="center">状态</td>
                <td align="center">操作</td>
            </tr>
        </thead>
        <tr class="item list-template-item" id="item_{id}">
            <td align="left"><a href="{url}" target="_blank">{name}</a></td>
            <td align="left">
                <div class="clearfix" style="max-height:50px;overflow:hidden;max-width:400px">
                    {Introduction}
                </div>
            </td>
            <td align="center">{author}</td>
            <td align="center">{InstallDate}</td>
            <td align="center"><span class="is-{enabled}"></span></td>
            <td align="center">
                <div class="btn-group btn-group-sm">
                    <button class="btn btn-default btn-sm ui-dialog stop-{enabled}" data-custom-params="title:'插件关闭',url:'@Url.ActionUrl("Set")?act=close&pluginName={pluginName}',width:'750px',height:'380px'">关闭</button>
                    <button class="btn btn-success btn-sm ui-dialog open-{enabled}" data-custom-params="title:'插件开启',url:'@Url.ActionUrl("Set")?act=open&pluginName={pluginName}',width:'750px',height:'420px'">开启</button>
                    <button class="btn btn-default btn-sm ui-dialog stop-{enabled}" data-custom-params="title:'插件更新',url:'@Url.ActionUrl("Index","PluginUpgrade")?pluginName={pluginName}',width:'80%',height:'80%'">更新</button>
                    <button class="btn btn-default btn-sm ui-dialog unload-{enabled}" data-custom-params="title:'插件卸载',url:'@Url.ActionUrl("Set")?act=uninstall&pluginName={pluginName}',width:'750px',height:'380px'">卸载</button>
                </div>
            </td>
        </tr>
    </table>
</div>

<script type="text/javascript">
    $(".navTabs").children().InitTab(function () { LoadData() }); //初始化选项卡，并设置回调函数为LoadData()
    //绑定数据
    var $container = $('#tb_list');
    function LoadedInit()
    {
        $(".lb-enabled-1").text("已启用").addClass("label-success");
        $(".lb-enabled-0").text("已关闭").addClass("label-default");
        $(".stop-0").hide();
        $(".open-1").hide();
        $(".unload-1").hide();
        $(".install-date-0").remove();
    }


    function LoadData() {
        var url = "@Url.ActionUrl("PageListData")";
        $container.ListBind({ url: url, callBack: "LoadedInit" });
    }
    LoadData();


    function CallBack()
    {
        var url = "@Url.ActionUrl("PageListData")";
        $("#tb_list").ListBind({ url: url, callBack: "RestartApplication" });
    }

    function RestartApplication()
    {
        LoadedInit();
        var url = "@Url.ActionUrl("RestartApplication","Default")";
        var Data = Ajax({ type: "post", async: false, url: url });
    }

</script>
